//log.js
//公共属性放在log对象里
const log = {
  data() {
      return {
          name: undefined,
          time: undefined
      }
  },
  created() {
      if (!this.name) {
          throw new Error('need page name')
      }
      this.time = new Date()
      console.log(`${this.name}created`);
  },
  beforeDestroy() {
      const now = new Date()
      console.log(`${this.name}destoroied,show${now - this.time}ms`);
  }
}
//导出log
export default log